#ifndef LIST_H
#define LIST_H
#include <ctime>
#include <iostream>
#include "entry.h"

class List
{
    public:
        //constructor, destructor
        List():first(NULL),last(NULL),db(0),poz(0){};
        ~List();

        //list in and out operators
        friend std::string& operator>>(std::string& s, List& a);
        friend std::ostream& operator<<(std::ostream& s, List& a);

        //node is a chained-list item with two pointers one to the previous and other to the next, also has an entry value
        struct Node{
            Node* next;
            Node* prev;
            Entry* ent;
            //node constructor
            Node(Entry* _ent, Node* _next, Node* _prev):ent(_ent),next(_next),prev(_prev){};
        };

        //list methods
        void pozPlus(){++poz;}         //increases list-viewing position
        void pozMinus(){--poz;}        //decreases list-viewing position
        int getPoz()const{return poz;} //returns position
        int getDb()const{return db;}   //returns the amount of entries in the list

        //list item methods
        void open(int which)const;
        void save(std::string _name, std::string _fpass)const;
        void add();

    private:
        Node* first;   //head of list
        Node* last;    //end of list
        int db;        //amount of items in list
        int poz;       //viewing position
};

#endif // LIST_H
